package com.authine.cloudpivot.ext.applicationservice;

import java.util.Map;

import javax.ws.rs.POST;
import javax.ws.rs.Path;

import io.swagger.v3.oas.annotations.Operation;
import org.apache.commons.collections4.map.HashedMap;

import com.alibaba.cola.dto.SingleResponse;
import com.authine.cloudpivot.ext.applicationservice.base.ApplicationBaseService;
import com.authine.cloudpivot.ext.dto.LogisticsDto;
import com.authine.cloudpivot.ext.utils.logistics.LogisticsUtils;

import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;

import static com.authine.hermes.app.launcher.service.ApplicationServiceFoundation.CUSTOM_SERVICE;

@Path("LogisticsService")
@Slf4j
public class LogisticsService extends ApplicationBaseService{

	@Path("queryLogistics")
	@POST
    @Operation(summary = "公用接口-物流查询", tags = CUSTOM_SERVICE, description = "waybillNum必填，快递为顺丰快递，收件人/发件人phone后四位必填")
	public SingleResponse<Map<String, Object>> queryLogistics(@Parameter LogisticsDto dto) {
	    if(dto==null)return SingleResponse.buildFailure("-1", "物流信息必填");
		Map<String, Object> resLogistics = new HashedMap<String, Object>();
		Object res = LogisticsUtils.queryLogistics(dto.getCompanyCode(), dto.getWaybillNum(), dto.getPhone());
		resLogistics.put("resLogistics", res);
        return SingleResponse.of(resLogistics);
	}
	
}
